package com.sn.author.common.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
public enum CollectionStatusEnum {
    AWAIT(0,"等待"),
    EXECUTE(10,"执行中"),
    FINISH(20,"完成"),
    FAILED(30,"失败");

    private Integer status;

    private String desc;

    CollectionStatusEnum(Integer status, String desc) {
        this.status = status;
        this.desc = desc;
    }

    public static Optional<CollectionStatusEnum> match(Integer status) {
        return Arrays.stream(CollectionStatusEnum.values())
                .filter(t -> t.getStatus().equals(status))
                .findFirst();
    }
}
